package com.cli.springboot_mdc.controller;

import com.cli.springboot_mdc.task.MdcRunnable;
import com.cli.springboot_mdc.task.SingletonMdcRunnable;
import com.cli.springboot_mdc.util.ThreadPoolExecutorMdcWrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: xiongmin
 * @since create by 2022/7/13 18:19
 */
@Slf4j
@RestController
public class HelloController {
    @Autowired
    private ThreadPoolExecutorMdcWrapper mdcTestThreadPool;

    @Autowired
    private SingletonMdcRunnable singletonMdcRunnable;

    @GetMapping
    public String helloMdc() {
        log.info("test");
        log.debug("只有在开发环境开可以看见我哟！！");

        MdcRunnable mdcRunnable = new MdcRunnable();

        mdcTestThreadPool.execute(mdcRunnable);
        mdcTestThreadPool.execute(singletonMdcRunnable);
        return  "helloMdc";
    }
}


